package com.sk.bilibili.view.fragment.main.home;

import android.view.View;

import com.sk.bilibili.adapter.pager.main.DynamicFragmentAdapter;
import com.sk.bilibili.bean.Member;
import com.sk.bilibili.databinding.FragmentMainDynamicBinding;
import com.sk.bilibili.event.MainMenuEvent;
import com.sk.bilibili.model.fragment.main.home.DynamicModel;
import com.sk.bilibili.utils.DataUtils;
import com.sk.bilibili.view.fragment.BaseFragment;

import org.greenrobot.eventbus.EventBus;

public class DynamicFragment extends BaseFragment<FragmentMainDynamicBinding, DynamicModel> {

    @Override
    protected void afterSetView() {
        initHeader();
        initViewPager();
    }

    private void initViewPager() {
        bind.vpShow.setAdapter(new DynamicFragmentAdapter(getChildFragmentManager()));
        bind.tlShow.setupWithViewPager(bind.vpShow);
        bind.vpShow.setCurrentItem(1);
    }

    private void initHeader() {
        model.loadMember();
        bind.avAvatar.setOnClickListener(v -> EventBus.getDefault().post(MainMenuEvent.closeEvent()));
        bind.ivPub.setOnClickListener(v -> toast("请在Web端操作"));
    }

    public void loadMemberSuccess(Member member) {
        bind.avAvatar.setRes(member.getAvatar(),member.getExtra().getPendant());
    }

}